package com.easy.controller;

import com.easy.bean.Maintenance_record;
import com.easy.service.MaintenanceRecordService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/maintenanceRecord")
public class MaintenanceRecordController {
    
    @Autowired
    private MaintenanceRecordService maintenanceRecordService;
    
    /**
     * 添加维护记录
     */
    @PostMapping("/add")
    public Result add(@RequestBody Maintenance_record maintenanceRecord) {
        return maintenanceRecordService.add(maintenanceRecord);
    }
    
    /**
     * 删除维护记录
     */
    @DeleteMapping("/del")
    public Result del(@RequestParam Integer id) {
        return maintenanceRecordService.del(id);
    }
    
    /**
     * 修改维护记录
     */
    @PutMapping("/edit")
    public Result edit(@RequestBody Maintenance_record maintenanceRecord) {
        return maintenanceRecordService.edit(maintenanceRecord);
    }
    
    /**
     * 根据ID查询维护记录
     */
    @GetMapping("/one")
    public Result one(@RequestParam Integer id) {
        return maintenanceRecordService.one(id);
    }
    
    /**
     * 查询所有维护记录
     */
    @GetMapping("/all")
    public Result all(@RequestParam(required = false) Integer equipment_id,
                      @RequestParam(required = false) Integer technician_id) {
        return maintenanceRecordService.all(equipment_id, technician_id);
    }
    
    /**
     * 分页查询维护记录
     */
    @GetMapping("/page")
    public Result page(Page page, Maintenance_record maintenanceRecord) {
        return maintenanceRecordService.page(page, maintenanceRecord);
    }
}